#!/usr/bin/python
# coding=utf8
#
# Copyright (C) 2011 XNData contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


__author__ = "zhangchitc@gmail.com"


class Status:

    status_id = ""
    content = ""
    author_id = ""
    author_name = ""
    pub_time = None     # should be a datetime object

    def __init__ (self, status_id = None, content = None, 
                author_id = None, author_name = None, pub_time = None):
        self.status_id = status_id
        self.content = content
        self.author_id = author_id
        self.author_name = author_name
        self.pub_time = pub_time

    def __repr__ (self):
        ret = ""
        ret += "status_id = %s\n" % self.status_id
        ret += "content = %s\n" % self.content
        ret += "author_id = %s\n" % self.author_id
        ret += "author_name = %s\n" % self.author_name
        ret += "pub_time = %s\n" % self.pub_time
        return ret

    def __str__ (self):
        return self.__repr__ ()


class StatusList:

    user_id = ""
    cur_page = -1
    slist = []

    def __init__ (self, user_id = None, cur_page = None):
        self.user_id = user_id
        self.cur_page = cur_page
        self.slist = []

    def __repr__ (self):
        ret = ""
        ret += "cur_page = %d\n" % self.cur_page
        for i, status in zip(xrange (len (self.slist)), self.slist):
            ret += " " * 12 + "******  [%dth status]  *******\n" % i
            ret += str (status)
        return ret
    
    def __str__ (self):
        return self.__repr__ ()

    def addStatus (self, status):
        self.slist.append (status)

    def __len__ (self):
        return len (self.slist)

    def __getitem__ (self, index):
        return self.slist[index]

